<?php
if (isset($_POST['desp']) && isset($_POST['from']) && isset($_POST['to'])) {
    $desp = $_POST['desp'];
    $from = $_POST['from'];
    $to = $_POST['to'];
    $link = mysql_connect("localhost", "admin", "Xurpas123");
    mysql_select_db("smsnic", $link);

    $result1 = mysql_query("SELECT * 
FROM  `smsprg` where `desc`='$desp' and fecha_ini='$from' and fecha_fin='$to'", $link) or die(mysql_error());
    if (mysql_num_rows($result1)) {
        ?>
        <script>
            alert('Lo sentimos, pero ya existe un envio programado con el mismo motivo o descripcion para ese rango de fechas!');
        </script>
        <?php
    } else {

        mysql_query("INSERT INTO `smsprg` (`desc`, `fecha_ini`, `fecha_fin`) VALUES ('$desp', '$from', '$to')");
        $result1 = mysql_query("SELECT * 
FROM  `smsprg` where `desc`='$desp' and fecha_ini='$from' and fecha_fin='$to'", $link) or die(mysql_error());
        if (mysql_num_rows($result1)) {
            while ($prg = @mysql_fetch_array($result1)) {
                $id = $prg['id'];
            }
        }
    }
    if (isset($id)) {
        ?>
        <script>
            document.location.href= "prgsms.php?id=<?php echo $id; ?>"
        </script>
        <?php
    }
    mysql_close();
}


require('functions.php');
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <title>A2P</title>
        <link href="css/styles_menu.css" rel="stylesheet" type="text/css" />
        <style type="text/css">
            <!--
            /* Terence Ordona, portal[AT]imaputz[DOT]com		 */
            /* http://creativecommons.org/licenses/by-sa/2.0/	*/
            /* begin some basic styling here					 */
            body {
                background: #FFF;
                color: #000;
                font: normal normal 12px Verdana, Geneva, Arial, Helvetica, sans-serif;
                margin: 10px;
                padding: 0
            }
            table, td, a {
                color: #000;
                font: normal normal 12px Verdana, Geneva, Arial, Helvetica, sans-serif
            }
            h1 {
                font: normal normal 18px Verdana, Geneva, Arial, Helvetica, sans-serif;
                margin: 0 0 5px 0
            }
            h2 {
                font: normal normal 16px Verdana, Geneva, Arial, Helvetica, sans-serif;
                margin: 0 0 5px 0
            }
            h3 {
                font: normal normal 13px Verdana, Geneva, Arial, Helvetica, sans-serif;
                color: #008000;
                margin: 0 0 15px 0
            }
            /* end basic styling								 */
            /* define height and width of scrollable area. Add 16px to width for scrollbar		 */
            div.tableContainer {
                clear: both;
                border: 1px solid #963;
                height: 285px;
                overflow: auto;
                width: 756px
            }
            /* Reset overflow value to hidden for all non-IE browsers. */
            html>body div.tableContainer {
                overflow: hidden;
                width: 756px
            }
            /* define width of table. IE browsers only				 */
            div.tableContainer table {
                float: left;
                width: 740px
            }
            /* define width of table. Add 16px to width for scrollbar.		  */
            /* All other non-IE browsers.										*/
            html>body div.tableContainer table {
                width: 756px
            }
            /* set table header to a fixed position. WinIE 6.x only									  */
            /* In WinIE 6.x, any element with a position property set to relative and is a child of	  */
            /* an element that has an overflow property set, the relative value translates into fixed.	*/
            /* Ex: parent element DIV with a class of tableContainer has an overflow property set to auto */
            thead.fixedHeader tr {
                position: relative
            }
            /* set THEAD element to have block level attributes. All other non-IE browsers			*/
            /* this enables overflow to work on TBODY element. All other non-IE, non-Mozilla browsers */
            html>body thead.fixedHeader tr {
                display: block
            }
            /* make the TH elements pretty */
            thead.fixedHeader th {
                background: #C96;
                border-left: 1px solid #EB8;
                border-right: 1px solid #B74;
                border-top: 1px solid #EB8;
                font-weight: normal;
                padding: 4px 3px;
                text-align: left
            }
            /* make the A elements pretty. makes for nice clickable headers				*/
            thead.fixedHeader a, thead.fixedHeader a:link, thead.fixedHeader a:visited {
                color: #FFF;
                display: block;
                text-decoration: none;
                width: 100%
            }
            /* make the A elements pretty. makes for nice clickable headers				*/
            /* WARNING: swapping the background on hover may cause problems in WinIE 6.x  */
            thead.fixedHeader a:hover {
                color: #FFF;
                display: block;
                text-decoration: underline;
                width: 100%
            }
            /* define the table content to be scrollable											 */
            /* set TBODY element to have block level attributes. All other non-IE browsers			*/
            /* this enables overflow to work on TBODY element. All other non-IE, non-Mozilla browsers */
            /* induced side effect is that child TDs no longer accept width: auto					 */
            html>body tbody.scrollContent {
                display: block;
                height: 262px;
                overflow: auto;
                width: 100%
            }
            /* make TD elements pretty. Provide alternating classes for striping the table */
            /* http://www.alistapart.com/articles/zebratables/							 */
            tbody.scrollContent td, tbody.scrollContent tr.normalRow td {
                background: #FFF;
                border-bottom: none;
                border-left: none;
                border-right: 1px solid #CCC;
                border-top: 1px solid #DDD;
                padding: 2px 3px 3px 4px
            }
            tbody.scrollContent tr.alternateRow td {
                background: #EEE;
                border-bottom: none;
                border-left: none;
                border-right: 1px solid #CCC;
                border-top: 1px solid #DDD;
                padding: 2px 3px 3px 4px
            }
            /* define width of TH elements: 1st, 2nd, and 3rd respectively.		 */
            /* Add 16px to last TH for scrollbar padding. All other non-IE browsers. */
            /* http://www.w3.org/TR/REC-CSS2/selector.html#adjacent-selectors		*/
            html>body thead.fixedHeader th {
                width: 200px
            }
            html>body thead.fixedHeader th + th {
                width: 240px
            }
            html>body thead.fixedHeader th + th + th {
                width: 316px
            }
            /* define width of TD elements: 1st, 2nd, and 3rd respectively.		 */
            /* All other non-IE browsers.											*/
            /* http://www.w3.org/TR/REC-CSS2/selector.html#adjacent-selectors		*/
            html>body tbody.scrollContent td {
                width: 200px
            }
            html>body tbody.scrollContent td + td {
                width: 240px
            }
            html>body tbody.scrollContent td + td + td {
                width: 300px
            }
            -->
        </style>
        <script type="text/javascript" src="tabla/jquery.js"></script>
        <script src="js/jquery.functions.js" type="text/javascript"></script>

        <style type="text/css">
            a{
                text-decoration:none;
            }
            img{
                border:none;
            }
            #contenedor{
                width:800px;
                margin:auto;
                margin-top:20px;
                border:2px solid #C0C0C0;
                background-color:#F2F2F2;
                padding-bottom:20px;
            }
            small{
                font-size:9px;
            }

            table{
                width:700px;
                margin:auto;
            }
            td{
                border-bottom:0px solid #D3D3D3;
                padding:5px 0px 5px;
                text-align: left;
            }

            th{
                background-color:#CDCDCD;
                padding:5px 0px 5px;
            }

            form{
                border:2px solid #C0C0C0;
                margin:auto;
                margin-bottom:20px;
            }

            form p{
                margin:auto;
                width:450px;
                margin-top:5px;
                margin-bottom:3px;
            }
            form input{
                border:1px solid #CCCCCC;
                padding:3px;
            }



            #resultado{	
                border:none;
            }

            .textos {
                text-align: left;
            }
            .textos label {
                text-align: left;
            }

            iframe{
                visibility:hidden;
                display:none;	

            }

            .frame{
                visibility:hidden;
                display:none;	
            }

            .progress-bar {
                border: 1px solid #56577A; 
                width: 200px; 
                margin: 5px; 
                padding: 1px; 
                background: #fff;
                float: left;
                text-align:center;
            }

            .bar {
                height: 15px;
                font-size: 11px;
                text-indent:-9000px;
                text-align:center;
            }

            #percentage{
                float: left;
                margin-left: 10px;
                margin-top:4px;
            }
        </style>

        <script src="progressbar.js" type="text/javascript"></script>
        <script type="text/javascript">
            var prefijos = new Array();

<?php
$conexion = mysql_connect("localhost", "admin", "Xurpas123");
mysql_select_db("smsnic", $conexion);
$result1 = mysql_query("SELECT prefijos FROM movistar", $conexion) or die(mysql_error());
if (mysql_num_rows($result1)) {
    $i = 0;
    while ($row1 = @mysql_fetch_array($result1)) {
        echo "prefijos[" . $i . "] = " . $row1['prefijos'] . ";";
        $i = $i + 1;
    }
}

mysql_close($conexion);
?>

    function validarfh(){
        var hora = document.getElementById('hora');
        var minutos = document.getElementById('min');

        if(hora.value=='' || minutos.value=='')
        {
            alert('Estimado usuario ingrese la hora exacta del envio');
            hora.focus();
            return false;
        }
        else
        {	
            if ((/^[0-9]+$/.test(hora.value) == false) || (/^[0-9]+$/.test(minutos.value) == false))
            {
                alert('Estimado usuario el campo de la hora no puede contener carateres.');
                hora.focus();
                return false;
            }

            else
            {
                if((parseInt(hora.value) > 23) || (parseInt(hora.value) < 0))
                {
                    alert('Estimado usuario el campo de la hora no es valido (0-23).');
                    hora.focus();
                    return false;
                }
                else
                {
                    if((parseInt(minutos.value) > 59) || (parseInt(minutos.value) < 0))
                    {
                        alert('Estimado usuario el campo de los minutos no es valido (0-59).');
                        minutos.focus();
                        return false;
                    }
                    else
                    {	
			
				
                        return true;
		
                    }
                }
            }
        }
    }



    function enviar(){
        //Capturando variables del mensaje
        var telefonos = jQuery.trim($('#msisdn').val());
        var elem = telefonos.split('\n');
        var mensaje = jQuery.trim($('#sms').val());  
        var x = 0;
        var audi = new Array();
        var frame = "";
        var fecha = document.getElementById('from').value;
        var fecha2 = document.getElementById('to').value;
        var hora = document.getElementById('hora').value+":"+document.getElementById('min').value;
	
        var seleccionado = document.getElementById('seleccionado').value;
        var edad = 0;
        var edad2 = 0;
	
        if(seleccionado==1)
        {
            edad =  document.getElementById('edad').value;
        }
        else if (seleccionado == 2)
        {
            edad =  document.getElementById('edad2').value;
        }
        else if (seleccionado == 3)
        {
            edad =  document.getElementById('edad3').value;
            edad2 =  document.getElementById('edad4').value;
        }
	
        if(mensaje=="")
        {
            alert("No ha ingresado el mensaje que se enviara...");
        }
        else
        {
        
        document.getElementById('cancelsent').disabled="disabled";
		
            for(var i=0; i< elem.length; i++) 
            {		
                x=0;	
                for(var j=0; j < prefijos.length; j++)
                {
			
                    if(elem[i].substring(0,4)==prefijos[j])
                    {
                        x=1;
							
                        audi[i] = document.createElement("IFRAME");
                        audi[i].id = "audi"+i;
                        frame="audi"+i;
                        audi[i].src = "enviosprg.php?telefono=505"+elem[i]+"&operadora=1&mensaje="+mensaje+"&estado=3&fecha="+fecha+"&hora="+hora+"&seleccionado="+seleccionado+"&edad="+edad+"&edad2="+edad2+"&fecha2="+fecha2+"&id=<?php echo $_GET['id']; ?>";	
                        document.body.appendChild(audi[i]);
                        //document.getElementById(frame).className='frame';	
							
                    }
				
                }
                if(x==0){
                    if(elem[i]!=""){					
                        audi[i] = document.createElement("IFRAME");
                        audi[i].id = "audi"+i;
                        frame="audi"+i;
                        audi[i].src = "enviosprg.php?telefono=505"+elem[i]+"&operadora=2&mensaje="+mensaje+"&estado=3&fecha="+fecha+"&hora="+hora+"&seleccionado="+seleccionado+"&edad="+edad+"&edad2="+edad2+"&fecha2="+fecha2+"&id=<?php echo $_GET['id']; ?>";	
                        document.body.appendChild(audi[i]);
                        //document.getElementById(frame).className='frame';	
                    }
							
                }
	
            }//Fin del ciclo de numeros

            initialize();
		
        }	
    }
	


    function cargar(){
        var indice = document.getElementById('grupo').selectedIndex;
        grupo = document.getElementById('grupo').options[indice].value;	

	
<?php
if (isset($_GET['grupo'])) {
    ?>
                document.location.href="prgsms.php?id=<?php echo $_GET['id']; ?>&grupo=<?php echo $_GET['grupo']; ?>,'"+grupo+"'";
    <?php
} else {
    ?>
                document.location.href="prgsms.php?id=<?php echo $_GET['id']; ?>&grupo='"+grupo+"'";
    <?php
}
?>

    }
    function agregar(x){
        //
        
        var variable = document.getElementById('var'+x);
        var msg = document.getElementById('sms');
        msg.value=msg.value+variable.name
	
	
    }

    //variable del sistema
    function agregarVS(x){

        var msg = document.getElementById('sms');
        msg.value=msg.value+x;
	
	
    }

    function cambiar(){

        id=document.getElementById("condicion").value;

        if(id=="0")
        {
	
            div = document.getElementById('Dcondicion');				
            div.style.display='none';
				
	
            div3 = document.getElementById('Dcondicion3');
            div3.style.display = 'none';
		
            div2 = document.getElementById('Dcondicion2');
            div2.style.display = 'none';
        }
        else if (id=="1")
        {
				
            div = document.getElementById('Dcondicion');
            document.getElementById('seleccionado').value= document.getElementById('condicion').value;

            div.style.display = '';
		
            div3 = document.getElementById('Dcondicion3');
            div3.style.display = 'none';
		
            div2 = document.getElementById('Dcondicion2');
            div2.style.display = 'none';
        }
        else if (id=="2")
        {
				
            div = document.getElementById('Dcondicion2');
            document.getElementById('seleccionado').value= document.getElementById('condicion').value;

            div.style.display = '';
		
            div3 = document.getElementById('Dcondicion3');
            div3.style.display = 'none';
		
            div1 = document.getElementById('Dcondicion');
            div1.style.display = 'none';
        }
        else if (id=="3")
        {
				
            div = document.getElementById('Dcondicion3');
            document.getElementById('seleccionado').value= document.getElementById('condicion').value;

            div.style.display = '';
		
            div2 = document.getElementById('Dcondicion2');
            div2.style.display = 'none';
		
            div1 = document.getElementById('Dcondicion');
            div1.style.display = 'none';
		
        }
	
	
    }

    function mostrarDIV()
    {
        div = document.getElementById('Dcondicion');
        document.getElementById("rp").value=id;
        div.style.display = "";
    }
		
    function ocultarDIV() {

        div = document.getElementById('Dcondicion');
				
        div.style.display='none';

    }
		
<?php
if (isset($_GET['grupo'])) {
    ?>
            function quitar(menos){
            		
                document.location.href="prgsms.php?id=<?php echo $_GET['id']; ?>&grupo=<?php echo $_GET['grupo']; ?>".replace(menos, "");
            			
            			
            }
            		
            		
            function cadcompare(){
                var indice = document.getElementById('grupo').selectedIndex;
                var grupo = document.getElementById('grupo').options[indice].value;	
                if("<?php echo $_GET['grupo']; ?>".indexOf(grupo)!=-1)
                {
                    alert("Ya agrego este grupo.");
                    return false;
                }
                else{
                    return true;
                }
            		
            }
    <?php
}
?>
		
    function ver(){
        return false;
    }
		
        </script>

        <style type="text/css" title="currentStyle">

            @import "examples_support/themes/smoothness/jquery-ui-1.8.4.custom.css";
            .ui-datepicker{
                display:none;
            }
        </style>
        <script type="text/javascript" src="js/jquery.nivo.slider.pack.js"></script>
        <script src="js/jquery.ui.core.js"></script>
        <script src="js/jquery.ui.widget.js"></script>
        <script src="js/jquery.ui.datepicker.js"></script>

        <script type="text/javascript">
            $(window).load(function() {
                $('#slider').nivoSlider();
            });
        </script>

        <script type="text/javascript">
            $(function() {
                var dates = $( "#from, #to" ).datepicker({
                    defaultDate: "-5w",
                    changeMonth: true,
                    numberOfMonths: 3,
                    onSelect: function( selectedDate ) {
                        var option = this.id == "from" ? "minDate" : "maxDate",
                        instance = $( this ).data( "datepicker" ),
                        date = $.datepicker.parseDate(
                        instance.settings.dateFormat ||
                            $.datepicker._defaults.dateFormat,
                        selectedDate, instance.settings );
                        dates.not( this ).datepicker( "option", option, date );
                    }
                });
            });
        </script>
        <script>
            function valida_prgenvia(){
                //valido el nombre
                if (document.frm_rango.from.value.length==0 || document.frm_rango.to.value.length==0){
                    alert("Seleccione un rango de fechas...");
		
                    return false;
                } 
                else {
                    if(document.getElementById('desp').value==''){
                        alert("Debe especificar una descripción o motivo para el envio.");
                        return false;
                    }
                    else{
                        return true;
                    }
                }
            }
            
            function cancelarenvios(){
            				document.getElementById('cancelarenv').src="delprgsms.php?id=<?php echo $_GET['id']; ?>";            				
							location.href="menu_sms.php";

            }
        </script>


    </head> 

    <body bgcolor="#FFFFFF" id="send_sms"> 
        <iframe id="mov" height="1px" style="visibility:hidden">
        </iframe>
        <iframe id="cancelarenv" height="1px" style="visibility:hidden">
        </iframe>
        <form id="frm_rango" name="frm_rango" method="post" action="prgsms.php" style="border:none; width:auto;" onSubmit="return valida_prgenvia();">
            <?php
            if (isset($_GET['id'])) {
                $link = mysql_connect("localhost", "admin", "Xurpas123");
                mysql_select_db("smsnic", $link);

                $result1 = mysql_query("SELECT * 
FROM  `smsprg` where id =" . $_GET['id'], $link) or die(mysql_error());
                if (mysql_num_rows($result1)) {
                    while ($prg = @mysql_fetch_array($result1)) {
                        $desp1 = $prg['desc'];
                        $fecha1 = $prg['fecha_ini'];
                        $fecha2 = $prg['fecha_fin'];
                    }
                }
                mysql_close();
            }
            ?>
            <table width="100%" align="center" >
                <tr>
                    <td align="center">
                        <center>
                            <label for="from" >Descripción:</label>
                            <input type="text" width="200" id="desp" name="desp" size="50" maxlength="100" value="<?php echo $desp1; ?>"  />
                        </center>
                    </td>
                    <td rowspan="2" align="center">
                     <center>

                        <input type="submit" class="but" name="generar" value="Generar" id="generar"  onclick="valida_envia();" />
                         <?php
    if (isset($_GET['id'])) {
        ?>

                        <br/>
                         <br/>
                        <input type="button" class="but" name="cancelsent" value="Cancelar" id="cancelsent"  onclick="cancelarenvios();" />
<?php
}
?>
</center>

                    </td>

                </tr>
                <tr>
                    <td align="center">
                        <center>

                            <label for="from" >&nbsp;Desde</label>
                            <input name="from" type="text"  id="from" size="10"  value="<?php echo $fecha1; ?>" />
                            <label for="to" >hasta</label>
                            <input type="text" id="to"   name="to"  size="10" value="<?php echo $fecha2; ?>">
                        </center>
                    </td>

                </tr>
            </table>
        </form>
        <table align="center" style="visibility:hidden" id="envios">
            <tr>
                <td colspan="3" align="center">
                    <center>
                        <form action="javascript: cargar();" method="get" class="textos" style="border:none; width:auto;" onsubmit="return cadcompare();">
                            <label>Seleccione un grupo:<select style="width:auto" id="grupo">
                                    <?php
                                    $conexion = mysql_connect("localhost", "admin", "Xurpas123");
                                    mysql_select_db("smsnic", $conexion);
                                    $result1 = mysql_query("SELECT * FROM grupos", $conexion) or die(mysql_error());
                                    if (mysql_num_rows($result1)) {
                                        while ($row1 = @mysql_fetch_array($result1)) {
                                            $dato = $row1['nombre'];
                                            echo "<option>";
                                            echo $dato;
                                            echo "</option>";
                                        }
                                    }
                                    mysql_close($conexion);
                                    ?>
                                </select></label>&nbsp;&nbsp;&nbsp;<input type="submit" value="Cargar Grupo" /><br/><br/>
                        </form>
                    </center>
                </td>
            </tr>
            <?php
            if (isset($_GET['grupo'])) {
                ?>
                <tr>
                    <td colspan="3">
                        <form onsubmit="return ver();" id="grupos">
                            <?php
                            $x = "";
                            $grupo1 = explode(',', $_GET['grupo']);
                            foreach ($grupo1 as $value) {
                                if ($value != '') {

                                    echo "<input type=\"submit\" value=\"" . str_ireplace("'", "", $value) . "\" id=\"$value\" onclick=\"quitar(this.id);\"/>";

                                    $x = $value;
                                }
                            }
                            if ($x == "") {
                                ?>
                                <script>
                                    document.getElementById('grupos').style.visibility="hidden";
                                </script>
                                <?php
                            }
                            ?>
                        </form>
                    </td>
                </tr>
                <?php
            }
            ?>
            <form action="Javascript: enviar();" method="get" class="textos" style="border:none;" onSubmit="Javascript: return validarfh();">
                <tr>
                    <td width="255px" valign="top">
                        <label>T&eacute;lefonos:<br/>

                            <textarea class="text" type="text" name="msisdn" id="msisdn" style="height:265px; width:205px;max-height:267px; max-width:205px;" cols="8" ><?php
            if (isset($_GET['grupo'])) {
                $grupo = "";

                $grupo2 = explode(',', $_GET['grupo']);
                foreach ($grupo2 as $valor) {
                    if ($valor <> '') {
                        $grupo = $grupo . $valor . ", ";
                    }
                }
                $max = strlen($grupo);
                $grupo = substr($grupo, 0, $max - 2);

                if ($grupo <> "") {
                    $conexion = mysql_connect("localhost", "admin", "Xurpas123");
                    mysql_select_db("smsnic", $conexion);
                    $result1 = mysql_query("SELECT telefono FROM
cliente inner join grupos on cliente.grupo=grupos.id where grupos.nombre in ($grupo)", $conexion) or die(mysql_error());
                    if (mysql_num_rows($result1)) {
                        while ($row1 = @mysql_fetch_array($result1)) {
                            $dato = $row1['telefono'];
                            echo "$dato\n";
                        }
                    }
                    mysql_close($conexion);
                }
            }
            ?>
                            </textarea>    
                        </label>

                    </td>
                    <td width="405px" valign="top">
                        <label>Mensaje: <div class="container4">
                                <div class="menu4">

                                    <ul>
                                        <li class="system"><a href="#"><img src="css/system.png" align="absmiddle" width="20" /> Variables del Sistema</a>
                                            <ul>
                                                <li><a href="#" onClick="Javascript: agregarVS('@nombre ');"><table><tr><td align="center" width="20px"><img src="css/name.png" align="absmiddle" width="20px" /></td><td align="center">&nbsp;Nombre del Cliente</td></tr></table></a></li>
                                                <li><a href="#" onClick="Javascript: agregarVS('@cell ');" ><table><tr><td align="center" width="20px"><img src="css/phone.png" align="absmiddle"width="20px" /></td><td align="center">&nbsp;Celular del Cliente</td></tr></table></a></li>


                                            </ul>
                                        </li>
                                    </ul>

                                </div>
                            </div>



                            <br />
                            <br />
                            <textarea class="text" type="text" name="sms" id="sms" style="height:170px; width:305px;max-height:170px; max-width:305px;" cols="10" rows="50"  tabindex="0"></textarea>
                        </label>
                        <br/><br/>

                        <br /><br />
                        <label>Ingrese la hora del envio:</label>
                        <input type="text" maxlength="2" size="2" id="hora"/>
                        &nbsp;:&nbsp;
                        <input type="text" maxlength="2" size="2" id="min"/>
                        <br/><br/>
                        <label>Filtro por Edad:</label>

                        <select id="condicion" name="condicion" onChange="Javascript: cambiar();">
                            <option value="0">Todo el Grupo </option>
                            <option value="1">Mayores de </option>
                            <option value="2">Menor de </option>
                            <option value="3">Entre la edad de</option>
                        </select>
                        <input type="hidden" id="seleccionado" name"selecccionado" />
                               <br />
                            <br />
                            <div name="Dcondicion" id="Dcondicion" style="display:none;"  >
                                <label id="slash" name="slash" >Mayores de:</label>
                                <input type="text" name="edad" id="edad" style="width:30px"   maxlength="2" sise="2"  /> <label id="anios" name="anios" >años</label>

                            </div>
                            <div name="Dcondicion2" id="Dcondicion2" style="display:none;"  >
                                <label id="slash2" name="slash2" >Menores de:</label>
                                <input type="text" name="edad2" id="edad2" style="width:30px"   maxlength="2" sise="2"  /> <label id="anios2" name="anios2" >años</label>

                            </div>
                            <div name="Dcondicion3" id="Dcondicion3" style="display:none;"  >
                                <label id="slash3" name="slash3" >Entre la edad de:</label>
                                <input type="text" name="edad3" id="edad3" style="width:30px"   maxlength="2" sise="2"  /> <label id="anios3" name="anios3" > y </label>
                                <input type="text" name="edad4" id="edad4" style="width:30px"   maxlength="2" sise="2"  /> <label id="anios3" name="anios3" > años </label>

                            </div>
                            <br />
                            <br/>
                            <div align="center">
                                <input type="submit" value="Enviar"/>
                            </div>
                    </td>
                    <td width="405px" valign="top">
                        <div id="tableContainer" class="tableContainer" style="width:auto">
                            <table border="0" cellpadding="0" cellspacing="0" style="width:auto" class="scrollTable">
                                <thead class="fixedHeader">
                                    <tr>
                                        <th style="color:#FFF; text-decoration:underline">Variables:</th>
                                    </tr>
                                </thead>
                                <tbody class="scrollContent">
                                    <?php
                                    $conexion = mysql_connect("localhost", "admin", "Xurpas123");
                                    mysql_select_db("smsnic", $conexion);
                                    $result1 = mysql_query("SELECT * FROM variables", $conexion) or die(mysql_error());
                                    if (mysql_num_rows($result1)) {
                                        while ($row1 = @mysql_fetch_array($result1)) {
                                            ?>
                                            <tr>
                                                <td><a id="var<?php echo $row1['id'] ?>" href="#" name="<?php echo $row1['valor'] ?>" onclick="agregar(<?php echo $row1['id'] ?>);"><?php echo $row1['var'] ?></a></td>

                                            </tr>
                                            <?php
                                        }
                                    }
                                    ?>
                                </tbody>
                            </table>
                        </div>

                    </td>
                </tr>
                <tr>
                    <td colspan="3" align="center" valign="middle">
                        <div class="progress-bar">          
                            <div id ="sample" class="bar">100%</div>
                        </div>
                        <div id ="percentage"></div>
                    </td>
                </tr>
            </form>  
        </table>
        <?php
        if (isset($_GET['id'])) {
            ?>
        <script>
            document.getElementById('envios').style.visibility="visible";
            document.getElementById('desp').disabled="disabled";
            document.getElementById('from').disabled="disabled";
            document.getElementById('to').disabled="disabled";
            document.getElementById('generar').disabled="disabled";
            function regresar(){
            location.href="menu_sms.php";
            }
        </script>
        <?php        
    }
    ?>

    </body>
</html>